{include file="public/header" /}
<body>
<form class="layui-form" id="form" action="{:url('save')}">
<div class="x-body layui-anim" style="padding-top: 0">
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">基本信息</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <div class="layui-form-item">
                    <label class="layui-form-label">介绍</label>
                    <div class="layui-input-block">
                        <input type="text" name="introduce" lay-verify="required" lay-reqtext="请输入视频介绍"
                               placeholder="请输入视频介绍" class="layui-input" value="{$info?$info.introduce:''}"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">分类</label>
                    <div class="layui-input-inline">
                        <select name="cate_id" id="cate_id" lay-verify="required" lay-reqtext="请选择分类" lay-filter="cate">
                            <option value="">请选择</option>
                            {foreach name="cate_list" item="vo"}
                            <option value="{$vo.id}" {if isset($info) && $info.cate_id== $vo.id}selected{/if}>{$vo.title}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">关联商品</label>
                    <div class="layui-input-inline">
                        <select name="product_id" id="product_id"  lay-reqtext="请选择分类" lay-filter="cate">
                            <option value="">请选择</option>
                            {foreach name="product_list" item="vo"}
                            <option value="{$vo.id}" {if isset($info) && $info.product_id== $vo.id}selected{/if}>{$vo.title}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item ">
                    <label class="layui-form-label">封面</label>
                    <div class="layui-input-block">
                        <div class="layui-tab-item layui-show" style="width: 260px;">
                            <div class="layui-upload-drag uploadImage">
                                <i class="layui-icon"></i>
                                <p>点击上传，或将文件拖拽到此处</p>
                                <div>
                                    <hr>
                                    <img src="{$info?$info.cover:''}" class="layui-upload-img showImage" alt="上传成功后渲染" style="max-width: 100%">
                                    <input type="hidden" name="cover" value="{$info?$info.cover:''}" class="inpImage" />
                                </div>
                            </div>
                            <input class="layui-upload-file" type="file" accept="" name="file">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item video" >
                    <label class="layui-form-label">上传视频</label>
                    <div class="layui-input-inline" style="display: flex">
                        <div class="layui-tab-item layui-show" style="width: 300px">
                            <div class="layui-upload-drag uploadVideo" data-token="{$token}" style="padding: 15px;width: 100px">
                                <i class="layui-icon"></i>
                                <div>
                                    <hr>
                                    <div class="layui-progress" lay-filter="video">
                                        <div class="layui-progress-bar" lay-percent="0%"></div>
                                    </div>
                                    <input type="hidden" id="video_link" name="video_link" value="{$info?$info.link:''}" />
                                </div>
                            </div>
                            <input class="layui-upload-file" type="file" accept="" name="file">
                        </div>
                        <div style="padding-left: 10px;">
                            <video src="{$info?$info.video_link_url:''}" controls style="width: 200px;" class="layui-upload-img videoLink"></video>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>

    <input type="hidden" id="id" name="id" value="{$Request.param.id}">
    <div class="layui-form-item layui-layout-admin">
        <div class="layui-input-block">
            <div class="layui-footer" style="left: 0;">
                <a class="layui-btn" lay-filter="save" lay-submit formObj="#form">保存</a>
            </div>
        </div>
    </div>
</div>
</form>
</body>
{include file="public/footer" /}
<script type="text/javascript" src="/static/admin/js/uploads.js"></script>
<script>
    $(function () {
        //layui初始化
        layui.use(['form', 'upload'], function () {
            form.on('radio(is_free)', function (data) {
                if (data.value === '2') {
                    $('.free_price').show();
                } else {
                    $('.free_price').hide();
                }
            });

            form.on('radio(type)', function (data) {
                $('.video').hide();
                $('.audio').hide();
                $('.'+data.value+'').show();
            });
        })
    });
</script>
</html>